package com.snap.awesomeserial.service;

public class ExpException extends Exception {

    public static final int ERROR_CODE_UNKNOWN = 0;//未知错误
    public static final int ERROR_CODE_READ_CONFIG = 1;//读取本机配置失败
    public static final int ERROR_CODE_OPEN_SERIAL_PORT = 2;//打开串口失败
    public static final int ERROR_CODE_OPEN_POWER = 3;//打开电源失败
    public static final int ERROR_CODE_OPEN_LID = 4;//打开热盖失败
    public static final int ERROR_CODE_ENV_TEMP = 5;//环境温度异常
    public static final int ERROR_CODE_TEC_TEMP = 6;//设置tec温度失败
    public static final int ERROR_CODE_LIGHTING_FAILED = 7;//采光指令失败
    public static final int ERROR_CODE_LIGHTING_STATE_NO_RESPONSE = 8;//采光状态无响应
    public static final int ERROR_CODE_LIGHTING_DATA_GET_FAILED = 9;//获取采光数据失败

    public final int errorCode;

    public ExpException(int errorCode) {
        this.errorCode = errorCode;
    }

    public ExpException(int errorCode, String errorMessage) {
        super(errorMessage);
        this.errorCode = errorCode;
    }

    public static String getDesc(int code) {
        switch (code) {
            case 1:
                return "读取本机实验配置失败！";
            case 2:
                return "打开串口失败！";
            case 3:
                return "打开电源失败！";
            case 4:
                return "热盖控温失败！";
            case 5:
                return "环境温度过高！";
            case 6:
                return "设置温度失败！";
            case 7:
                return "采光失败(1)!";//开始采光指令通信失败
            case 8:
                return "采光失败(2)!";//采光状态指令长时间无响应
            case 9:
                return "采光失败(3)!";//获取采光数据失败
            default:
                return "未知错误(" + code + ")!";
        }
    }
}
